home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-02 / atibgi.zip / ATIVW256.PAS < prev    next >
Pascal/Delphi Source File  |  1990-05-27  |  5KB  |  125 lines

  1.  
  2.  
  3. {$F+}
  4. function detect_ATI_VGA_Wonder : integer;
  5. {
  6. This a standard autodetect function as outlines in the Turbo Pascal Manual.
  7. If the card is detected, the highest available mode number is returned.
  8. Otherwise a negative number indicating an error is returned.
  9.  
  10.  
  11. copyright(c) 1990 by Peter F. Jones. ALL RIGHTS RESERVED.
  12. This software may be used and included in other programs as
  13. outlined in your software license.
  14. }
  15. const copyright1: string[60] = 'copyright(c) 1990 by Peter F. Jones. ALL RIGHTS RESERVED.';
  16. function test_bios_mode(bios_mode:byte):boolean;
  17. var AX : word;
  18.   begin
  19.        inline( $8A / $0846);  { mov al,[bp+8]   or  mov al,[bp+8]   or  bios_mode }
  20.                               { al has desired mode on input           }
  21.                               { on return ax = 0xffff if not supported }
  22.  
  23.        inline( $55        );  { push      bp           }
  24.        inline( $8B / $EC  );  { mov       bp,sp        }
  25.        inline( $06        );  { push      es           }
  26.        inline( $B4 / $12  );  { mov       ah,12h       }
  27.        inline( $BB / $5506);  { mov       bx,5506h     }
  28.        inline( $BD / $FFFF);  { mov       bp,0ffffh    }
  29.        inline( $CD / $10  );  { int       10h          }
  30.        inline( $8B / $C5  );  { mov       ax,bp        }
  31.        inline( $07        );  { pop       es           }
  32.        inline( $5D        );  { pop       bp           }
  33.  
  34.        inline( $89 / $fc46);  { mov [bp-4],ax mov AX,ax    }
  35.  
  36.  
  37.   test_bios_mode := AX<>$FFFF;
  38.  
  39. end;
  40.  
  41. function test_512K_memory:boolean;
  42. var AX : word;
  43.   begin
  44.  
  45.  
  46.      inline($06);              {    push es         ;save registers es and bx                     }
  47.      inline($53);              {    push bx                                                       }
  48.      inline($B8 / $C000);      {    mov  ax,0c000h  ;define storage location of EXTENDED_REG      }
  49.      inline($8E / $C0);        {    mov  es,ax                                                    }
  50.      inline($BB / $10 / $00);  {    mov  bx,10h                                                   }
  51.      inline($26 / $8B / $17);  {    mov  dx,es:[bx] ;get the value of EXTENDED_REG from contents  }
  52.                                {                    ;of the storage location C000:0010h           }
  53.      inline($5B);              {    pop  bx         ;restore registers es and bx                  }
  54.      inline($07);              {    pop  es                                                       }
  55.      inline($FA);              {    cli                                                           }
  56.                                {                    ;mov       dx,EXTENDED_REG                    }
  57.      inline($B0 / $BB);        {    mov       al,0bbh                                             }
  58.      inline($EE);              {    out       dx,al                                               }
  59.      inline($42);              {    inc       dx                                                  }
  60.      inline($EC);              {    in        al,dx                                               }
  61.      inline($FB);              {    sti                                                           }
  62.      inline($24 / $20);        {    and       al,020h                                             }
  63.  
  64.      inline( $89 / $fc46);     {    mov [bp-4],ax mov AX,ax                                       }
  65.  
  66.  
  67.     test_512K_memory := (AX and $20)<>0;
  68.  
  69.  
  70.  
  71. end;
  72.    type manufacturer_type = array[0..8] of char;
  73.    var found : boolean;
  74.        manufacturer : ^manufacturer_type;
  75.        chip_set : ^manufacturer_type;
  76.        counter : integer;
  77.    const manufacturer_id : string[9] = '761295520';
  78.    const chip_set_id : string[2] = '31';
  79.  
  80.  
  81.      begin
  82.         detect_ATI_VGA_Wonder := -11;   {return error if not found}
  83.  
  84.         found := true;
  85.         manufacturer := ptr($C000,$31);
  86.         chip_set     := ptr($C000,$40);
  87.  
  88.         for counter := 0 to 8 do
  89.           if manufacturer^[counter] <> manufacturer_id[counter+1] then found := false;
  90.         if not found then exit;        {return error}
  91.         for counter := 0 to 1 do
  92.           if chip_set^[counter] <> chip_set_id[counter+1] then found := false;
  93.         if not found then exit;        {return error}
  94.  
  95.        if test_512K_memory then  {if 512k then try hires modes}
  96.           begin
  97.              if test_bios_mode($63) then  {check 800x600}
  98.                   begin
  99.                      detect_ATI_VGA_Wonder := 3;
  100.                      exit;
  101.                   end;
  102.  
  103.              if test_bios_mode($62) then  {check 640x480}
  104.                   begin
  105.                      detect_ATI_VGA_Wonder := 2;
  106.                      exit;
  107.                   end;
  108.           end;
  109.  
  110.              if test_bios_mode($61) then  {check 640x400}
  111.                   begin
  112.                      detect_ATI_VGA_Wonder := 1;
  113.                      exit;
  114.                   end;
  115.  
  116.              if test_bios_mode($13) then  {check 320x200}
  117.                   begin
  118.                      detect_ATI_VGA_Wonder := 0;
  119.                      exit;
  120.                   end;
  121.      end;
  122. {$F-}
  123.  
  124.  
  125.